Deprecate positional conversion options in add_to_nwbfile and interface init#1663
Deprecate positional conversion options in add_to_nwbfile and interface init#1663h-mayorquin merged 3 commits intomainfrom
add_to_nwbfile and interface init#1663Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enforces keyword-only arguments for conversion options across all data interfaces in NeuroConv. The changes ensure that __init__ methods only accept file_path, folder_path, or file_paths as positional arguments, while add_to_nwbfile methods only accept nwbfile and metadata positionally. All other parameters must be passed as keyword arguments.
Changes:
- Added deprecation handling using
*argspattern in__init__andadd_to_nwbfilemethods across ~100 data interfaces - Replaced existing
*keyword-only markers with*argstemporarily to maintain backward compatibility during deprecation period - Updated super() calls to use keyword arguments where necessary to avoid passing positional arguments to parent methods
Reviewed changes
Copilot reviewed 70 out of 70 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| src/neuroconv/datainterfaces/**/*.py | Added *args deprecation pattern with FutureWarning for positional conversion options in init and add_to_nwbfile methods across all interface files |
| docs/developer_guide/style_guide.rst | Documented the new convention requiring keyword-only arguments for conversion options with code examples |
| CHANGELOG.md | Added entry documenting the keyword-only argument enforcement and deprecation timeline |
Comments suppressed due to low confidence (2)
src/neuroconv/datainterfaces/ophys/femtonics/femtonicsdatainterface.py:161
- This import of module warnings is redundant, as it was previously imported on line 3.
src/neuroconv/datainterfaces/ecephys/cellexplorer/cellexplorerdatainterface.py:246 - This class does not call BaseRecordingExtractorInterface.init during initialization. (CellExplorerRecordingInterface.init may be missing a call to a base class init)
class CellExplorerRecordingInterface(BaseRecordingExtractorInterface):
| # v0.9.2 (Upcoming) | ||
|
|
||
| ## Removals, Deprecations and Changes | ||
| * Enforced keyword-only arguments across all data interfaces: `__init__` methods now only accept `file_path`/`folder_path`/`file_paths` as positional arguments, and `add_to_nwbfile` methods only accept `nwbfile` and `metadata` as positional arguments. Existing positional usage in `add_to_nwbfile` will emit a `FutureWarning` and will be removed on or after August 2026. [PR #1663](https://github.com/catalystneuro/neuroconv/pull/1663) |
There was a problem hiding this comment.
The CHANGELOG entry should mention that both __init__ and add_to_nwbfile methods will emit FutureWarning for positional argument usage. Currently, it only mentions add_to_nwbfile. Consider updating to: "Existing positional usage in both __init__ and add_to_nwbfile will emit a FutureWarning and will be removed on or after August 2026."
| * Enforced keyword-only arguments across all data interfaces: `__init__` methods now only accept `file_path`/`folder_path`/`file_paths` as positional arguments, and `add_to_nwbfile` methods only accept `nwbfile` and `metadata` as positional arguments. Existing positional usage in `add_to_nwbfile` will emit a `FutureWarning` and will be removed on or after August 2026. [PR #1663](https://github.com/catalystneuro/neuroconv/pull/1663) | |
| * Enforced keyword-only arguments across all data interfaces: `__init__` methods now only accept `file_path`/`folder_path`/`file_paths` as positional arguments, and `add_to_nwbfile` methods only accept `nwbfile` and `metadata` as positional arguments. Existing positional usage in both `__init__` and `add_to_nwbfile` will emit a `FutureWarning` and will be removed on or after August 2026. [PR #1663](https://github.com/catalystneuro/neuroconv/pull/1663) |
| @@ -1,4 +1,5 @@ | |||
| import json | |||
| import warnings | |||
There was a problem hiding this comment.
Module 'warnings' is imported with both 'import' and 'import from'.
| @@ -1,3 +1,4 @@ | |||
| import warnings | |||
There was a problem hiding this comment.
Module 'warnings' is imported with both 'import' and 'import from'.
| import warnings |
| @@ -1,3 +1,4 @@ | |||
| import warnings | |||
There was a problem hiding this comment.
Module 'warnings' is imported with both 'import' and 'import from'.
| FutureWarning, | ||
| stacklevel=2, | ||
| ) | ||
| icephys_experiment_type = positional_values.get("icephys_experiment_type", icephys_experiment_type) |
There was a problem hiding this comment.
Variable icephys_experiment_type is not used.
| ) | ||
| gain = positional_values.get("gain", gain) | ||
| xml_file_path = positional_values.get("xml_file_path", xml_file_path) | ||
| verbose = positional_values.get("verbose", verbose) |
There was a problem hiding this comment.
Variable verbose is not used.
| gain = positional_values.get("gain", gain) | ||
| xml_file_path = positional_values.get("xml_file_path", xml_file_path) | ||
| verbose = positional_values.get("verbose", verbose) | ||
| es_key = positional_values.get("es_key", es_key) |
There was a problem hiding this comment.
Variable es_key is not used.
| ) | ||
| stream_name = positional_values.get("stream_name", stream_name) | ||
| block_index = positional_values.get("block_index", block_index) | ||
| stub_test = positional_values.get("stub_test", stub_test) |
| include_roi_centroids = positional_values.get("include_roi_centroids", include_roi_centroids) | ||
| include_roi_acceptance = positional_values.get("include_roi_acceptance", include_roi_acceptance) | ||
| mask_type = positional_values.get("mask_type", mask_type) | ||
| plane_segmentation_name = positional_values.get("plane_segmentation_name", plane_segmentation_name) |
There was a problem hiding this comment.
Variable plane_segmentation_name is not used.
| ) | ||
| noise_std = positional_values.get("noise_std", noise_std) | ||
|
|
||
| super().__init__(filename=file_path, noise_std=noise_std) |
There was a problem hiding this comment.
Keyword argument 'filename' is not a supported parameter name of method AxonaRecordingInterface.init.
Keyword argument 'noise_std' is not a supported parameter name of method AxonaRecordingInterface.init.
| super().__init__(filename=file_path, noise_std=noise_std) | |
| super().__init__(file_path=file_path) |
|
@h-mayorquin I've opened a new pull request, #1665, to work on those changes. Once the pull request is ready, I'll request review from you. |
pauladkisson
left a comment
There was a problem hiding this comment.
It was a lot of files, so I wanted to try out Copilot review to see if it would catch anything that I missed. As far as I can tell, the changes look good. Copilot's review seems to have caught a bunch of off-target stuff. Some of which may be legitimate and others that are really not. So I'll let you decide what to do with all that.
Thanks, this makes sense. That's partly why I shared with you #1664 as an entry point (which included these changes. Yes, I checked some of the github copilot review and I think it went off the rails. Thanks for the review. |
Allows only nwbfile and metadata for
add_to_nwbfileAllows file_path, file_paths and folder_path for
__init__